package com.kanq.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kanq.mapper.KanqAiHistoryAnswerMapper;
import com.kanq.pojo.entity.KanqAiHistoryAnswer;
import com.kanq.service.KanqAiHistoryAnswerService;
import org.springframework.stereotype.Service;

/**
 * @author wangchong
 * @description 针对表【kanq_ai_history_answer】的数据库操作Service实现
 * @createDate 2025-06-04 14:18:02
 */
@Service
public class KanqAiHistoryAnswerServiceImpl extends ServiceImpl<KanqAiHistoryAnswerMapper, KanqAiHistoryAnswer>
        implements KanqAiHistoryAnswerService {

    @Override
    public void saveAnswer(Long questionId, String string) {
        KanqAiHistoryAnswer kanqAiHistoryAnswer = new KanqAiHistoryAnswer();
        kanqAiHistoryAnswer.setHistoryQuestionId(questionId);
        kanqAiHistoryAnswer.setContent(string);
        this.save(kanqAiHistoryAnswer);
    }

    @Override
    public Long createAnswerRecord(Long questionId) {
        KanqAiHistoryAnswer kanqAiHistoryAnswer = new KanqAiHistoryAnswer();
        kanqAiHistoryAnswer.setHistoryQuestionId(questionId);
        this.save(kanqAiHistoryAnswer);
        return kanqAiHistoryAnswer.getHistoryAnswerId();
    }

    @Override
    public void updateAnswer(Long aLong, String string) {
        this.update(Wrappers.<KanqAiHistoryAnswer>lambdaUpdate().set(KanqAiHistoryAnswer::getContent, string).eq(KanqAiHistoryAnswer::getHistoryAnswerId, aLong));
    }
}




